package com.LeetCode.Learning;
/*

使用暴力解法的思路：遍历每个元素x，查找是否存在与target-x相等的目标元素。这可以通过嵌套循环来实现。对于数组中的每个元素，都可以遍历整个数组来查找相应的目标元素。*/

public class Solution {
    public static int[] twoSum(int[] nums, int target) {
        int n = nums.length;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (nums[i] + nums[j] == target) {
                    return new int[] {i, j};
                }
            }
        }
        throw new IllegalArgumentException("No two sum solution");
    }

    public static void main(String[] args) {
        int[] nums = {2, 7, 11, 15};
        int target = 9;
        int[] result = twoSum(nums, target);
        if (result[0] == 0 && result[1] == 1) {
            System.out.println("测试通过");
        } else {
            System.out.println("测试失败");
        }
    }


}